//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_huddispmsgengine.sqf"
#include "x_setup.sqf"

while {true} do {
	waitUntil {count GVAR(msg_hud_array) > 0 && {alive player} && {!GVAR(msg_hud_shown)} && {!__pGetVar(xr_pluncon)}};
	[GVAR(msg_hud_array) select 0] spawn FUNC(HudDispMsg);
	GVAR(last_hud_msgs) set [count GVAR(last_hud_msgs), GVAR(msg_hud_array) select 0];
	if (count GVAR(last_hud_msgs) > 20) then {
		GVAR(last_hud_msgs) set [0,-1];
		GVAR(last_hud_msgs) = GVAR(last_hud_msgs) - [-1];
	};
	GVAR(msg_hud_array) set [0,-1];
	GVAR(msg_hud_array) = GVAR(msg_hud_array) - [-1];
};